/////////////////////////////////////////////////////////////////////////////
// Name:        maintoolbar.cpp
// Purpose:     
// Author:      Brant Young
// Modified by: 
// Created:     Mon May 14 21:46:51 2007
// RCS-ID:      
// Copyright:   Copyright (c) daodict.com 2007
// Licence:     GPL 2.0
/////////////////////////////////////////////////////////////////////////////
#include <wx/wx.h>

#include "maintoolbar.h"
#include "application.h"
#include "thememgr.h"
#include "prefers/prefersdialog.h"
#include "addons/addonsdialog.h"

/**
 * MainToolBar constructors
 */
MainToolBar::MainToolBar(wxWindow* p_parent) : wxToolBar(p_parent, ID_MAIN_TOOLBAR, \
                                       wxDefaultPosition, wxDefaultSize, \
                                       wxTB_FLAT|wxTB_HORIZONTAL|wxNO_BORDER|wxTB_TEXT | \
                                       wxTB_NODIVIDER )
{
    this->SetBackgroundColour(wxColour(247, 245, 204));
    this->SetToolBitmapSize(wxSize(24, 24));

    ThemeManager& theme_mgr = ThemeManager::get();

    // -----------------------------------------------------------
    wxBitmap& logo_bmp = theme_mgr.get_bitmap(_T("home-24.png"));
    this->AddTool(ID_LOGO, _T("Home"), logo_bmp, wxNullBitmap, wxITEM_NORMAL, _T("Daodict"),_("Wellcom"));

    wxBitmap& exit_bmp = theme_mgr.get_bitmap(_T("exit-24.png"));
    this->AddTool(ID_EXIT, _("Exit"), exit_bmp, wxNullBitmap, wxITEM_NORMAL, _("Exit This Program"));
    
    // -------------------
    this->AddSeparator();
    // -------------------
    
    wxBitmap& prefers_bmp = theme_mgr.get_bitmap(_T("preferences-24.png"));
    this->AddTool(ID_PREFERS, _("Preferences"), prefers_bmp, wxNullBitmap, wxITEM_NORMAL, _("Preferences"));
    
    wxBitmap& addons_bmp = theme_mgr.get_bitmap(_T("dictpack-24.png"));
    // this->AddTool(ID_ADDONS, _("Add-ons"), addons_bmp, wxNullBitmap, wxITEM_NORMAL, _("Add-ons"));
    this->AddTool(ID_ADDONS, _("Dictionary"), addons_bmp, wxNullBitmap, wxITEM_NORMAL, _("Dictionary"));
    
    /*wxBitmap& back_bmp = theme_mgr.get_bitmap(_T("back-24.png"));
    this->AddTool(ID_BACK, _(""), back_bmp, wxNullBitmap, wxITEM_NORMAL, _("Go Back"));
    this->EnableTool(ID_BACK,false);
    
    wxBitmap& forward_bmp = theme_mgr.get_bitmap(_T("forward-24.png"));
    this->AddTool(ID_HOME, _(""), forward_bmp, wxNullBitmap, wxITEM_NORMAL, _("Go Forward"));
    */
    
    wxBitmap& help_bmp = theme_mgr.get_bitmap(_T("help-24.png"));
    this->AddTool(ID_HELP, _("Help"), help_bmp, wxNullBitmap, wxITEM_NORMAL, _("Help Contents"));
    
    wxBitmap& about_bmp = theme_mgr.get_bitmap(_T("about-24.png"));
    this->AddTool(ID_ABOUT, _("About"), about_bmp, wxNullBitmap, wxITEM_NORMAL, _("About Daodict"));
    
    // -------------------
    this->AddSeparator();
    // -------------------

    this->Realize();
    this->InitEvents();

    /*
    wxComboBox* p_words_input_cbox = new wxComboBox(this, ID_INPUT, _T(""), wxDefaultPosition, \
                                                    wxSize(400, 32), 0, NULL, wxCB_DROPDOWN);
    p_words_input_cbox->SetToolTip(_("Words Input Bar"));
    this->AddControl(p_words_input_cbox);
    wxBitmap& find_bmp = theme_mgr.get_bitmap(_T("go-24.png"));
    this->AddTool(ID_FIND, _(""), find_bmp, wxNullBitmap, wxITEM_NORMAL, _("Find the words in the Words Input Bar"));

    wxBitmap& fuzzysearch_bmp = theme_mgr.get_bitmap(_T("fuzzysearch-24.png"));
    this->AddTool(ID_FIND, _(""), fuzzysearch_bmp, wxNullBitmap, wxITEM_NORMAL, _("Find the words in the Words Input Bar"));
    */
}


/**
 * MainToolBar destructor
 */

MainToolBar::~MainToolBar()
{
////@begin MainToolBar destruction
////@end MainToolBar destruction
}


void MainToolBar::InitEvents() {
	this->Connect(ID_HELP, wxEVT_COMMAND_TOOL_CLICKED, 
			(wxObjectEventFunction)&MainToolBar::OnHelp);
	
	this->Connect(ID_PREFERS, wxEVT_COMMAND_TOOL_CLICKED, 
			(wxObjectEventFunction)&MainToolBar::OnPrefers);
	
	this->Connect(ID_ADDONS, wxEVT_COMMAND_TOOL_CLICKED, 
			(wxObjectEventFunction)&MainToolBar::OnAddons);
	
	this->Connect(ID_EXIT, wxEVT_COMMAND_TOOL_CLICKED, 
			(wxObjectEventFunction)&MainToolBar::OnExit);
}

void MainToolBar::OnHelp(wxCommandEvent& event) {
	wxMessageBox(_("Help"));
	event.Skip();
}

void MainToolBar::OnPrefers(wxCommandEvent& event) {
	PrefersDialog dlg(this);
	
	dlg.ShowModal();
	event.Skip();
}

void MainToolBar::OnAddons(wxCommandEvent& event) {
	AddonsDialog dlg(this);
	dlg.ShowModal();
	event.Skip();
}

void MainToolBar::OnExit(wxCommandEvent& event) {
	wxGetApp().GetTopWindow()->Close();
	event.Skip();
}
